package com.hg.library.ui.gallery;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
import android.view.animation.Transformation;
import android.widget.Gallery;

/**
 * Created by ASUS-PC on 2016/4/14.
 */
public class Gallery3D extends Gallery {

    private GalleryManager galleryManager;

    public Gallery3D(Context context) {
        super(context);
    }

    public Gallery3D(Context context, AttributeSet attrs) {
        super(context, attrs);
        initParmeter();
    }

    private void initParmeter() {
        galleryManager = new GalleryManager(this);
        setChildrenDrawingOrderEnabled(true);
        setStaticTransformationsEnabled(true);
        galleryManager.setMaxZoom(0);
        galleryManager.setRotationAngle(20);
    }

    @Override
    protected int getChildDrawingOrder(int childCount, int i) {
        return galleryManager.ChildDrawingOrder(childCount,i);
    }

    @Override
    protected boolean getChildStaticTransformation(View child, Transformation t) {
        super.getChildStaticTransformation(child, t);
        return galleryManager.ChildStaticTransformation(child, t);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        galleryManager.onSizeChanged();
    }

    public int getRotationAngle() {
        return galleryManager.getRotationAngle();
    }

    //设置角度
    public void setRotationAngle(int maxRotationAngle) {
        galleryManager.setRotationAngle(maxRotationAngle);
    }

    public int getMaxZoom() {
        return galleryManager.getMaxZoom();
    }

    public void setMaxZoom(int maxZoom) {
        galleryManager.setMaxZoom(maxZoom);
    }

}
